package com.lzy.system.business.service.impl;

import com.lzy.exception.BusException;
import com.lzy.system.business.dto.SysBusGroupOrderDTO;
import com.lzy.system.business.dto.convert.SysBusGroupConvert;
import com.lzy.system.business.entity.SysBusGroup;
import com.lzy.system.business.mapper.SysBusGroupMapper;
import com.lzy.system.business.service.ISysBusGroupService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 业务模型分组 服务实现类
 * </p>
 *
 * @author lcc
 * @since 2024-01-15
 */
@Service
public class SysBusGroupServiceImpl extends ServiceImpl<SysBusGroupMapper, SysBusGroup> implements ISysBusGroupService {

    private SysBusGroupConvert sysBusGroupConvert;

    @Autowired
    public SysBusGroupServiceImpl(SysBusGroupConvert sysBusGroupConvert) {
        this.sysBusGroupConvert = sysBusGroupConvert;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveOrderIndex(List<SysBusGroupOrderDTO> list) throws BusException {
        List<SysBusGroup> sysBusGroups = sysBusGroupConvert.orderDtoToEntitys(list);
        this.updateBatchById(sysBusGroups);
    }
}
